package com.lemon.rpcframe.dao;

import java.io.File;

import org.apache.log4j.Logger;

import com.lemon.rpcframe.dao.basedao.DAOHelper;

/**
 * @ClassName DBHelper
 * @Description TODO
 * @author yangning02@58.com
 * @date 2014-3-13
 */
public class DBHelper {

    private static final Logger logger = Logger.getLogger(DBHelper.class);

    public final long idSeed = 1317398400000L;
    private DAOHelper daoHelper = null;
    private volatile static DBHelper instance = null;

    private DBHelper() {
    }

    public DAOHelper getdaoHelper() {
        return daoHelper;
    }

    public static DBHelper getInstance() {
        if (instance == null) {
            synchronized (DBHelper.class) {
                if (instance != null)
                    return instance;
                instance = new DBHelper();
                try {
                    String dbpath = File.separator + "config" + File.separator + "db.properties";
                    logger.info(dbpath);
                    instance.daoHelper = DAOHelper.createIntrance(dbpath);
                    logger.info("");
                } catch (Exception e) {
                    instance = null;
                    e.printStackTrace();
                }
            }
        }
        return instance;
    }

}
